package com.jinzhi.jzapi.utils;

import java.util.Optional;

public class TestUtil {
    public static void main(String[] args){
        String test = null;
        Optional<String> demo2 = Optional.ofNullable(test);
        System.out.println("ofNullable" + demo2);
//        Optional<String> demo1 = Optional.of(test);
//        System.out.println("of: " + demo1);
        // 结果图在下面


        String peo=null;
        String peo1="value";
        Optional.ofNullable(peo).ifPresent(s -> System.out.println("这个不打印"));
        Optional.ofNullable(peo1).ifPresent(s -> System.out.println("这个打印"+s));
    }

}
